#define _CRT_SECURE_NO_WARNINGS 1
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include<math.h>
#include<stdlib.h>
#include<stdio.h>
#include<unordered_map>
using namespace std;

class Solution {
public:
    int findMaxLength(vector<int>& nums) {
        int sum = 0, ret = 0;
        unordered_map<int, int> hash;
        hash[0] = 0;
        for (int i = 0; i < nums.size(); i++)
        {
            if (nums[i] == 0) sum -= 1;
            else sum += 1;
            if (hash.count(sum - 0)) ret = max((i + 1 - hash[sum]), ret);
            else hash[sum] = i + 1;
        }
        return ret;
    }
};

int main() {
    return 0;
}